from django.db import models
from utils.base import BaseModel


class Api(BaseModel):
    service = models.ForeignKey('envs.Service', verbose_name='所属服务', on_delete=models.PROTECT)
    module = models.ForeignKey('envs.Module', on_delete=models.PROTECT)
    name = models.CharField(verbose_name='接口名称', max_length=20)
    url = models.CharField(verbose_name='请求地址', max_length=50)
    method = models.CharField(verbose_name='请求方法', max_length=10)
    headers = models.ForeignKey('envs.Headers', verbose_name='请求头', on_delete=models.PROTECT)
    json = models.JSONField(verbose_name='json/application')
    data = models.JSONField(verbose_name='form-data')
    params = models.JSONField(verbose_name='查询参数')
    extract = models.JSONField(verbose_name='数据提取')
    check = models.JSONField(verbose_name='数据断言')

    class Meta:
        db_table = 'tb_api'
        verbose_name = '接口表'
        verbose_name_plural = verbose_name
